// 由于微信小程序环境的特殊性，我们不使用luxon库，而是使用原生JavaScript的Date对象

// 如果需要使用我们自己的time.js工具函数，可以使用以下导入方式
// const { formatTimeByParts } = require('../../utils/time.js');

Page({

  /**
   * 页面的初始数据
   */
  data: {
		scheduleList: [
			{ date: 1756665600000, type: null, description: null },
			{ date: 1756752000000, type: null, description: null },
			{ date: 1756838400000, type: null, description: null },
			{ date: 1756924800000, type: null, description: null },
			{ date: 1757011200000, type: "抗战胜利日", description: "纪念抗战胜利" },
			{ date: 1757097600000, type: null, description: null },
			{ date: 1757184000000, type: "中元节", description: "中元节习俗" },
			{ date: 1757270400000, type: null, description: null },
			{ date: 1757356800000, type: null, description: null },
			{ date: 1757443200000, type: null, description: null },
			{ date: 1757529600000, type: null, description: null },
			{ date: 1757616000000, type: null, description: null },
			{ date: 1757702400000, type: "教师节", description: "庆祝教师节" },
			{ date: 1757788800000, type: null, description: null },
			{ date: 1757875200000, type: null, description: null },
			{ date: 1757961600000, type: null, description: null },
			{ date: 1758048000000, type: null, description: null },
			{ date: 1758134400000, type: null, description: null },
			{ date: 1758220800000, type: null, description: null },
			{ date: 1758307200000, type: "计算机课", description: "计算机课程安排" },
			{ date: 1758393600000, type: null, description: null },
			{ date: 1758480000000, type: null, description: null },
			{ date: 1758566400000, type: null, description: null },
			{ date: 1758652800000, type: null, description: null },
			{ date: 1758739200000, type: null, description: null },
			{ date: 1758825600000, type: null, description: null },
			{ date: 1758912000000, type: null, description: null },
			{ date: 1758998400000, type: null, description: null },
			{ date: 1759084800000, type: "秋分", description: "秋分节气" },
			{ date: 1759171200000, type: null, description: null },
			{ date: 1759257600000, type: "国庆节", description: "庆祝国庆" },
			{ date: 1759344000000, type: "国庆节", description: "庆祝国庆" },
			{ date: 1759430400000, type: "国庆节", description: "庆祝国庆" },
			{ date: 1759516800000, type: "国庆节", description: "庆祝国庆" },
			{ date: 1759603200000, type: "国庆节", description: "庆祝国庆" }
		]
	},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    // 处理scheduleList，将date转换为月/日格式
    this.processScheduleDates();
  },

  /**
   * 处理scheduleList中的日期格式
   */
  processScheduleDates() {
		const data = this.data.scheduleList
		const list = data.map(item => {
			// 使用原生JavaScript的Date对象将毫秒时间戳转换为月/日格式
			const date = new Date(item.date);
			const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始，需要+1
			const day = String(date.getDate()).padStart(2, '0');
			item.date = `${month}/${day}`;
			return item;
		})
		
		// 使用setData更新页面数据
		this.setData({
			scheduleList: list
		});
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

	}
})